/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package GUInemeanshop;

import components.NDialog;
import components.NLabel;
import components.NText;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Rectangle;
import java.awt.event.KeyListener;
import javax.swing.BorderFactory;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
import nemeanshop.NemeanShop;

/**
 *
 * @author havardaxelsen
 */
public class LogInBox extends NDialog{
    
    private NLabel username         = new NLabel("Username: ");
    private NLabel password         = new NLabel("Password: ");
    private NText un                = new NText();
    private JTextField pw           = new JPasswordField();
    private NemeanShop ns;
    
    
    
    public LogInBox(NemeanShop ns, Frame f, boolean d, KeyListener k){
        super(f,d);
        //this.setLocationRelativeTo(f);
        //this.setLocation(new Point(100,100));
        this.setSize(new Dimension(400,80));
        this.setUndecorated(true);
        
        un.addKeyListener(k);
        pw.addKeyListener(k);
        username.setBorder(BorderFactory.createEmptyBorder(5,20,5,20));
        password.setBorder(BorderFactory.createEmptyBorder(5,20,5,20));
        username.setForeground(Color.white);
        password.setForeground(Color.white);
        
        
        
        
        this.setLayout(new GridLayout(2,2));
        add(username);
        add(un);
        add(password);
        add(pw);
        this.ns = ns;
        
        
    }
    public String un(){
        return un.getText();
    }
    public String pw(){
        
        return pw.getText();
        
    }
    
    public void reset(){
        pw.setText("");
        un.setText("");
        setVisible(false);
    }
    
    public void setDialogLocation(Frame f) {
        Rectangle r = f.getBounds();
        int x = r.x + (r.width - this.getSize().width)/2;
        int y = r.y + (r.height - this.getSize().height)/2;
        this.setLocation(x, y);
    }
    
    
}
